﻿@using SquishIt.Framework;
@using JabbR
@using JabbR.Services
@model ApplicationSettings

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>JabbR - administration</title>
    @{ 
        WriteLiteral(Bundle.Css()
            .Add("~/Content/bootstrap.min.css")
            .Add("~/Content/bootstrap-responsive.min.css")
            .Add("~/Content/font-awesome.min.css")
            .Add("~/Content/themes/default/Chat.css")
            .Add("~/Content/emoji20.css")
            .Render("~/Content/JabbR_#.css"));
    }
</head>
<body class="administration">
    <section id="page" role="application">
        <header id="heading" role="heading">
            <div class="banner" role="banner">
                <h1>JabbR</h1>
            </div>
        </header>
        <div class="container">
            <div class="row" style="padding-top: 75px;">
                @Html.AlertMessages()
                <div class="row">
                    <div class="span12">
                        <span class="administration-title pull-left">@LanguageResources.Administration</span>
                    </div>
                </div>
                <hr />
            </div>
            <form class="form-horizontal" action="@Url.Content("~/administration")" method="POST">
                @Html.ValidationSummary()
                <fieldset id="generalSettings">
                    <legend>@LanguageResources.Administration_GeneralSettings</legend>
                    <div class="control-group">
                        <label class="control-label" for="allowUserRegistration">@LanguageResources.Administration_AllowUserRegistration</label>
                        <div class="controls">
                            @Html.CheckBox("allowUserRegistration", Model.AllowUserRegistration)
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="allowUserResetPassword">@LanguageResources.Administration_ResetPasswordAllowed</label>
                        <div class="controls">
                            @Html.CheckBox("allowUserResetPassword", Model.AllowUserResetPassword)
                        </div>
                    </div>                    
                    <div class="control-group">
                        <label class="control-label" for="requestResetPasswordValidThroughInHours">@LanguageResources.Administration_ResetPasswordValidDurationHours</label>
                        <div class="controls">
                            <input type="text" id="requestResetPasswordValidThroughInHours" name="requestResetPasswordValidThroughInHours" class="input-mini" value="@Model.RequestResetPasswordValidThroughInHours" />
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="allowRoomCreation">@LanguageResources.Administration_AllowRoomCreation</label>
                        <div class="controls">
                            @Html.CheckBox("allowRoomCreation", Model.AllowRoomCreation)
                        </div>
                    </div>
                </fieldset>
                <fieldset id="emailSettings">
                    <legend>@LanguageResources.Administration_EmailSettings</legend>
                    <div class="control-group">
                        <label class="control-label" for="emailSender">@LanguageResources.Administration_EmailSender</label>
                        <div class="controls">
                            @Html.TextBox("emailSender", "input-xlarge", "noreply@mysite.com")
                        </div>
                    </div>
                </fieldset>
                <fieldset id="encryption">
                    <legend>@LanguageResources.Administration_Encryption</legend>
                    <div class="control-group">
                        <label class="control-label" for="encryptionKey">@LanguageResources.Administration_EncryptionKey</label>
                        <div class="controls">
                            <input type="hidden" id="encryptionKey" name="encryptionKey" value="@Model.EncryptionKey"/>
                            <label class="control-label label-align-left">@Model.EncryptionKey</label>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="verificationKey">@LanguageResources.Administration_VerificationKey</label>
                        <div class="controls">
                            <input type="hidden" id="verificationKey" name="verificationKey" value="@Model.VerificationKey"/>
                            <label class="control-label label-align-left">@Model.VerificationKey</label>
                        </div>
                    </div>
                </fieldset>
                <fieldset id="storage">
                    <legend>@LanguageResources.Administration_Storage</legend>
                    <div class="control-group">
                        <label class="control-label" for="azureBlobStorageConnectionString">@LanguageResources.Administration_AzureBlobStorageConnectionString</label>
                        <div class="controls">
                            <input type="text" id="azureBlobStorageConnectionString" name="azureBlobStorageConnectionString" class="input-xlarge" value="@Model.AzureblobStorageConnectionString" placeholder="@LanguageResources.Administration_AzureBlobStorageConnectionString"/>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="maxFileUploadBytes">@LanguageResources.Administration_MaxFileUploadBytes</label>
                        <div class="controls">
                            <input type="text" id="maxFileUploadBytes" name="maxFileUploadBytes" class="input-xlarge" value="@Model.MaxFileUploadBytes" placeholder="@LanguageResources.Administration_MaxFileUploadBytes"/>
                        </div>
                    </div>
                </fieldset>
                <fieldset id="analytics">
                    <legend>@LanguageResources.Administration_Analytics</legend>
                    <div class="control-group">
                        <label class="control-label" for="googleAnalytics">@LanguageResources.Administration_AnalyticsGoogleId</label>
                        <div class="controls">
                            <input type="text" id="googleAnalytics" name="googleAnalytics" class="input-xlarge" value="@Model.GoogleAnalytics" placeholder="@LanguageResources.Administration_AnalyticsGoogleId"/>
                        </div>
                    </div>
                </fieldset>
                <fieldset id="identityProviders">
                    <legend>@LanguageResources.Administration_IdentityProviders</legend>
                    <div class="control-group">
                    </div>
                </fieldset>
                <div class="control-group">
                    <div class="controls">
                        <input type="submit" class="btn pull-right" value="@LanguageResources.SettingsSave" />
                    </div>
                </div>
                @Html.AntiForgeryToken()
            </form>
        </div>
    </section>
    <script src="@Url.Content("~/Scripts/jquery-2.0.3.min.js")"></script>
    <script src="@Url.Content("~/Scripts/bootstrap.min.js")"></script>
    <script type="text/javascript">
        (function ($) {
            // set the selected tab based on the hash
            var currentSection = document.location.hash || "#encryption";
            $('a[href="' + currentSection + '"]').tab('show');

            // always set the hash when we change tabs
            $('a[data-toggle="tab"]').on('shown', function (e) {
                document.location.hash = e.target.hash;
            });

            // make sure errors look pretty and bootstrap-y
            $('input.error').closest('.control-group').addClass('error');

            $('input[type="checkbox"]').click(function () {
                var $this = $(this),
                    name = $this.data('name'),
                    checked = $this.is(':checked') === true,
                    $hiddenField = $('input[type="hidden"][name="' + name + '"]');

                $hiddenField.attr('value', checked);
            });

            $('input[data-name="allowUserResetPassword"]').change(function () {
                var checked = $(this).is(':checked') === true;
                if (checked) {
                    $('#requestResetPasswordValid').removeAttr('disabled');
                }
                else {
                    $('#requestResetPasswordValid').attr('disabled', 'disabled');
                }
            });

        }(jQuery));
    </script>
</body>
</html>
